<template>
  <el-dialog
    :title="title"
    :visible.sync="dialogVisible"
    :close-on-click-modal="false"
    width="850px"
  >
    <div class="form-box">
      <el-form
        ref="form"
        :model="form"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-form-item label="模板类型" prop="bussinessType">
          <el-select v-model="form.bussinessType" placeholder="请选择" clearable >
            <el-option v-for="(item,key) in commonMaps.hetongTypeMap" :key="key" :label="item.name" :value="key"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="状态" prop="status">
          <el-radio-group v-model="form.status">
            <el-radio  :label="1">正常</el-radio>
            <el-radio  :label="2">停用</el-radio>
          </el-radio-group>
        </el-form-item>
        <div class="center">
          <el-button @click="close()">取消</el-button>
          <el-button type="primary" @click="submitForm('form')" v-loading="loading">提交</el-button>
        </div>
      </el-form>
    </div>
  </el-dialog>
</template>

<script>
import fadadaApi from "../../api/B2Cmanage/fadada"
export default {
  data() {
    return {
      dialogVisible: false,
      loading: false,
      typeList: [
        {
          name: "未配置",
          value: 0
        },
        {
          name: "入驻协议",
          value: 1
        },
        {
          name: "回收合同",
          value: 2
        },
        {
          name: "转让合同(长明)",
          value: 3
        },
        // {
        //   name: "销售合同",
        //   value: 3
        // }
      ],
    
      title: "设置",
      isEdit: false,
      // 表单参数
      form: {
        bussinessType:'',
        status:1
      },
    };
  },
  created() {
    // this.headers = {
    //   token:'Bearer ' + getToken() ,
    //   Authorization:'Bearer ' + getToken()
    // }
    // this.uploadImgUrl = process.env.VUE_APP_BASE_API + "/upload/app";
  },
  methods: {
    // 打开弹窗
    open(data) {
      this.form = data
      this.dialogVisible = true;
    },
    // 重置
    reset() {
      this.$refs.form.resetFields();
    },
    submitForm(formName) {
      this.$refs["" + formName].validate(valid => {
        if (valid) {
          fadadaApi.editmodel(this.form).then(res=>{
            // console.log("%c Line:82 🌶 res", "color:#7f2b82", res);
            if(res.code==200){
              this.$message({
                type:'success',
                message:'操作成功'
              })
              this.dialogVisible = false
              this.$parent.getList()
            }
          })
         
        } else {
          this.$alert("请填写完整！");
        }
      });
    },
   
    close() {
      this.dialogVisible = false;
    }
  }
};
</script>
<style scoped lang="css">
.center {
  text-align: center;
}

.hiddenupload >>> .el-upload--picture-card {
  display: none;
}
</style>
